package model.impl.network;

import java.awt.Color;
import java.awt.Graphics2D;

import org.resotc.model.Light;

import sim.engine.SimState;
import sim.engine.Steppable;
import sim.portrayal.DrawInfo2D;
import sim.portrayal.simple.OvalPortrayal2D;

public class LightImpl extends OvalPortrayal2D implements Light, Steppable {

	private Color color;

	public LightImpl(Color color) {
		this.color = color;
	}

	/**
	 * @see Light#getColor()
	 */
	public Color getColor() {
		return this.color;
	}

	/**
	 * @see Light#setColor()
	 */
	public void setColor(Color color) {
		this.color = color;
	}

	public final void draw(Object object, Graphics2D graphics, DrawInfo2D info) {
		if (this.color == Color.red)
			graphics.setColor(Color.red);
		else
			graphics.setColor(Color.green);

		// this code was stolen from OvalPortrayal2D
		int x = (int) (info.draw.x - info.draw.width / 2.0);
		int y = (int) (info.draw.y - info.draw.height / 2.0);
		int width = (int) (info.draw.width);
		int height = (int) (info.draw.height);
		graphics.fillOval(x, y, width, height);

	}

	public void step(SimState state) {

	}
}
